<?php

/**
 *
 * @author Zhang Di <zhangdi_me@163.com>
 */


namespace yiiwiki\storage;


use yii\base\Component;

/**
 * Class BaseStorage
 * @property integer $errorCode
 * @property string $errorMessage
 * @package yiiwiki\storage
 */
abstract class BaseStorage extends Component
{
    const ERROR_NONE = 0;

    /**
     * 上传的源文件不存在
     */
    const ERROR_NO_SOURCE_FILE = 100;

    public $errorCode = self::ERROR_NONE;

    public $errorMessage;

    /**
     * 将内容写入文件
     *
     * @param string $filename
     * @param string $content
     * @return mixed
     */
    abstract public function write($filename, $content);

    /**
     * 上传文件
     *
     * @param string $srcFilename
     * @param string $distFilename
     * @return mixed
     */
    abstract public function upload($srcFilename, $distFilename);

    /**
     * 获取文件内容
     *
     * @param string $filename
     * @return mixed
     */
    abstract public function get($filename);

    /**
     * 文件是否存在
     *
     * @param string $filename
     * @return boolean
     */
    abstract public function exists($filename);

    /**
     * 删除文件
     * @param $filename
     * @return boolean
     */
    abstract public function delete($filename);
}